home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / SNNSV32.ZIP / SNNSv3.2 / xgui / sources / bn_artmap.ph < prev    next >
Encoding:
Text File  |  1994-04-25  |  12.3 KB  |  350 lines

  1. /*****************************************************************************
  2.   FILE           : bn_artmap.ph
  3.   SHORTNAME      : bn_artmap
  4.   SNNS VERSION   : 3.2
  5.  
  6.   PURPOSE        : 
  7.   NOTES          :
  8.  
  9.   AUTHOR         : Kai-Uwe Herrmann
  10.   DATE           : 15.1.1993
  11.  
  12.   CHANGED BY     : 
  13.   IDENTIFICATION : @(#)bn_artmap.ph    1.7 3/2/94
  14.   SCCS VERSION   : 1.7
  15.   LAST CHANGE    : 3/2/94
  16.  
  17.              Copyright (c) 1990-1994  SNNS Group, IPVR, Univ. Stuttgart, FRG
  18.  
  19. ******************************************************************************/
  20. #ifndef _BN_ARTMAP_DEFINED_
  21. #define  _BN_ARTMAP_DEFINED_
  22.  
  23. /* begin global definition section */
  24.  
  25. void bn_createARTMAP (void);
  26.  
  27. /* end global definition section */
  28.  
  29.  
  30. /* begin private definition section */
  31.  
  32. /* Definition of the Output Function */
  33. #define OUTFUNC    "Out_Identity"
  34.  
  35.  
  36. /* Definition of the Activationfunctions */
  37. #define ACTF_INPa "Act_Identity"
  38. #define ACTF_CMPa "Act_at_least_2"
  39. #define ACTF_RECa "Act_Identity"
  40. #define ACTF_DELa "Act_at_least_2"
  41. #define ACTF_Da   "Act_at_least_1"
  42. #define ACTF_RSTa "Act_at_least_1"
  43. #define ACTF_G1a  "Act_at_least_2"
  44. #define ACTF_RIa  "Act_Product"
  45. #define ACTF_RCa  "Act_Identity"
  46. #define ACTF_RGa  "Act_less_than_0"
  47. #define ACTF_CLa  "Act_at_least_1"
  48. #define ACTF_NCa  "Act_ARTMAP_NCa"
  49. #define ACTF_RHOa "Act_Identity"
  50. #define ACTF_G2a  "Act_at_most_0"
  51.  
  52.  
  53. #define ACTF_INPb "Act_Identity"
  54. #define ACTF_CMPb "Act_at_least_2"
  55. #define ACTF_RECb "Act_Identity"
  56. #define ACTF_DELb "Act_at_least_2"
  57. #define ACTF_Db   "Act_at_least_1"
  58. #define ACTF_RSTb "Act_at_least_1"
  59. #define ACTF_G1b  "Act_at_least_2"
  60. #define ACTF_RIb  "Act_Product"
  61. #define ACTF_RCb  "Act_Identity"
  62. #define ACTF_RGb  "Act_less_than_0"
  63. #define ACTF_CLb  "Act_at_least_1"
  64. #define ACTF_NCb  "Act_ARTMAP_NCb"
  65. #define ACTF_RHOb "Act_Identity"
  66. #define ACTF_G2b  "Act_at_most_0"
  67.  
  68. #define ACTF_MAP  "Act_at_least_2"
  69. #define ACTF_D1   "Act_Identity"
  70. #define ACTF_RB   "Act_Product"
  71. #define ACTF_RM   "Act_Identity"
  72. #define ACTF_RG   "Act_less_than_0"
  73. #define ACTF_G    "Act_exactly_1"
  74. #define ACTF_CL   "Act_at_least_2"
  75. #define ACTF_NC   "Act_at_least_1"
  76. #define ACTF_RHO  "Act_Identity"
  77. #define ACTF_QU   "Act_Product"
  78. #define ACTF_DRHO "Act_ARTMAP_DRho"
  79.  
  80.  
  81.  
  82. /* Site names
  83. */
  84. #define SITE_NAME_RSTa_SELF    "ArtMap_Site_Rsta_Self"
  85. #define SITE_NAME_RSTa_SIGNAL  "ArtMap_Site_Rsta_Signal"
  86. #define SITE_NAME_REC_G1a      "ArtMap_Site_Rec_G1a"
  87. #define SITE_NAME_INP_G1a      "ArtMap_Site_Inp_G1a"
  88. #define SITE_NAME_INP_RIa      "ArtMap_Site_Inp_RIa"
  89. #define SITE_NAME_RHO_RIa      "ArtMap_Site_Rho_RIa"
  90.  
  91. #define SITE_NAME_RSTb_SELF    "ArtMap_Site_Rstb_Self"
  92. #define SITE_NAME_RSTb_SIGNAL  "ArtMap_Site_Rstb_Signal"
  93. #define SITE_NAME_REC_G1b      "ArtMap_Site_Rec_G1b"
  94. #define SITE_NAME_INP_G1b      "ArtMap_Site_Inp_G1b"
  95. #define SITE_NAME_INP_RIb      "ArtMap_Site_Inp_RIb"
  96. #define SITE_NAME_RHO_RIb      "ArtMap_Site_Rho_RIb"
  97.  
  98. #define SITE_NAME_ARTa_G       "ArtMap_Site_ARTa_G"
  99. #define SITE_NAME_ARTb_G       "ArtMap_Site_ARTb_G"
  100. #define SITE_NAME_B_RB         "ArtMap_Site_B_RB"
  101. #define SITE_NAME_RHO_RB       "ArtMap_Site_Rho_RB"
  102. #define SITE_NAME_CMPa_QU      "ArtMap_Site_Cmpa_QU"
  103. #define SITE_NAME_INPa_QU      "ArtMap_Site_Inpa_QU"
  104.  
  105. /* Site function names
  106. */
  107. #define SITE_FUNC_RSTa_SELF    "Site_WeightedSum"
  108. #define SITE_FUNC_RSTa_SIGNAL  "Site_at_least_2"
  109. #define SITE_FUNC_REC_G1a      "Site_at_most_0"
  110. #define SITE_FUNC_INP_G1a      "Site_at_least_1"
  111. #define SITE_FUNC_INP_RIa      "Site_WeightedSum"
  112. #define SITE_FUNC_RHO_RIa      "Site_WeightedSum"
  113.  
  114. #define SITE_FUNC_RSTb_SELF    "Site_WeightedSum"
  115. #define SITE_FUNC_RSTb_SIGNAL  "Site_at_least_2"
  116. #define SITE_FUNC_REC_G1b      "Site_at_most_0"
  117. #define SITE_FUNC_INP_G1b      "Site_at_least_1"
  118. #define SITE_FUNC_INP_RIb      "Site_WeightedSum"
  119. #define SITE_FUNC_RHO_RIb      "Site_WeightedSum"
  120.  
  121. #define SITE_FUNC_ARTa_G       "Site_at_least_1"
  122. #define SITE_FUNC_ARTb_G       "Site_at_least_1"
  123. #define SITE_FUNC_B_RB         "Site_WeightedSum"
  124. #define SITE_FUNC_RHO_RB       "Site_WeightedSum"
  125. #define SITE_FUNC_CMPa_QU      "Site_WeightedSum"
  126. #define SITE_FUNC_INPa_QU      "Site_Reciprocal"
  127.  
  128. /* Learning function name */
  129. #define LEARN_FUNC_NAME     "ARTMAP"
  130.  
  131. /* Update function name */
  132. #define UPDATE_FUNC_NAME    "ARTMAP_Stable"
  133.  
  134.  
  135.  
  136. /* Macros
  137. */
  138.  
  139.  
  140. /* returns 0 if x<=0 and 1 if x>0
  141. */
  142. #define POS_SIGN(x)            (((x) > 0) ? 1 : 0)
  143.  
  144.  
  145. #define NO_OF_SPECIAL_ab_UNITS   8   /* d1a to d3a (d1b to d3b) excluded */
  146. #define NO_OF_SPECIAL_UNITS      10   /* including d1 unit */
  147.  
  148. /* Absolute Unit-Nummer berechnet aus ihrer relativen Nummer im Layer */
  149. #define INPa_UNIT(y)            y
  150. #define CMPa_UNIT(y)            INPa_UNIT(f1aUnits) + y
  151. #define RECa_UNIT(y)            CMPa_UNIT(f1aUnits) + y
  152. #define DELa_UNIT(y)            RECa_UNIT(f2aUnits) + y
  153. #define RSTa_UNIT(y)            DELa_UNIT(f2aUnits) + 3 + y
  154.  
  155. #define MAP_UNIT(y)             RSTa_UNIT(f2aUnits) + NO_OF_SPECIAL_ab_UNITS + y
  156.  
  157. #define INPb_UNIT(y)            MAP_UNIT(f2bUnits) + NO_OF_SPECIAL_UNITS + y
  158. #define CMPb_UNIT(y)            INPb_UNIT(f1bUnits) + y
  159. #define RECb_UNIT(y)            CMPb_UNIT(f1bUnits) + y
  160. #define DELb_UNIT(y)            RECb_UNIT(f2bUnits) + y
  161. #define RSTb_UNIT(y)            DELb_UNIT(f2bUnits) + 3 + y
  162.  
  163. #define Da_UNIT(y)              DELa_UNIT(f2aUnits) + y
  164. #define Db_UNIT(y)              DELb_UNIT(f2bUnits) + y
  165. #define D1_UNIT                 MAP_UNIT(f2bUnits) + 1
  166.  
  167. #define SPECIAL_UNITS_a         RSTa_UNIT(f2aUnits) + 1
  168. #define SPECIAL_UNITS_b         RSTb_UNIT(f2bUnits) + 1
  169. #define SPECIAL_UNITS           D1_UNIT + 1
  170.  
  171. #define G1a_UNIT                 SPECIAL_UNITS_a
  172. #define G1b_UNIT                 SPECIAL_UNITS_b
  173. #define G_UNIT                   SPECIAL_UNITS
  174.  
  175. #define RIa_UNIT                 SPECIAL_UNITS_a + 1
  176. #define RIb_UNIT                 SPECIAL_UNITS_b + 1
  177. #define RB_UNIT                  SPECIAL_UNITS + 1
  178.  
  179. #define RCa_UNIT                 SPECIAL_UNITS_a + 2
  180. #define RCb_UNIT                 SPECIAL_UNITS_b + 2
  181. #define RM_UNIT                  SPECIAL_UNITS + 2
  182.  
  183. #define RGa_UNIT                 SPECIAL_UNITS_a + 3
  184. #define RGb_UNIT                 SPECIAL_UNITS_b + 3
  185. #define RG_UNIT                  SPECIAL_UNITS + 3
  186.  
  187. #define CLa_UNIT                 SPECIAL_UNITS_a + 4
  188. #define CLb_UNIT                 SPECIAL_UNITS_b + 4
  189. #define CL_UNIT                  SPECIAL_UNITS + 4
  190.  
  191. #define NCa_UNIT                 SPECIAL_UNITS_a + 5
  192. #define NCb_UNIT                 SPECIAL_UNITS_b + 5
  193. #define NC_UNIT                  SPECIAL_UNITS + 5
  194.  
  195. #define RHOa_UNIT                SPECIAL_UNITS_a + 6
  196. #define RHOb_UNIT                SPECIAL_UNITS_b + 6
  197. #define RHO_UNIT                 SPECIAL_UNITS + 6
  198.  
  199. #define G2a_UNIT                 SPECIAL_UNITS_a + 7
  200. #define G2b_UNIT                 SPECIAL_UNITS_b + 7
  201.  
  202. #define QU_UNIT                  SPECIAL_UNITS + 7
  203. #define DRHO_UNIT                SPECIAL_UNITS + 8
  204.  
  205.  
  206. /* Calculates the number of columns when no of units and no. of rows is given
  207. */
  208. #define NO_OF_COLS(units,rows)  ((int) (units/rows) + POS_SIGN(units % rows))
  209.  
  210. #define MAX(x,y)                ((x) > (y) ? (x) : (y))
  211.  
  212. /* No of columns for F1a, F2a, F1b, F2b */
  213. #define F1a_COLS                 NO_OF_COLS(f1aUnits, f1aRows)
  214. #define F2a_COLS                 NO_OF_COLS(f2aUnits, f2aRows)
  215. #define F1b_COLS                 NO_OF_COLS(f1bUnits, f1bRows)
  216. #define F2b_COLS                 NO_OF_COLS(f2bUnits, f2bRows)
  217.  
  218. /* Unit Positions */
  219. #define OFFSET_X                 0
  220. #define OFFSET_Y                 0
  221. #define INPa_X                   OFFSET_X + 1
  222. #define INPa_Y                   OFFSET_Y + 8
  223. #define CMPa_X                   INPa_X + MAX(F1a_COLS,F1b_COLS) + 1
  224. #define CMPa_Y                   INPa_Y
  225. #define RECa_X                   CMPa_X + MAX(F1a_COLS,F1b_COLS) + 3
  226. #define RECa_Y                   CMPa_Y
  227. #define DELa_X                   RECa_X + MAX(F2a_COLS,F2b_COLS) + 1
  228. #define DELa_Y                   RECa_Y
  229. #define RSTa_X                   DELa_X + MAX(F2a_COLS,F2b_COLS) + 1
  230. #define RSTa_Y                   DELa_Y
  231. #define D1a_X                    DELa_X
  232. #define D1a_Y                    DELa_Y + MAX(f1aRows,f2aRows) + 1
  233. #define D2a_X                    (RSTa_X + DELa_X) / 2
  234. #define D2a_Y                    D1a_Y
  235. #define D3a_X                    RSTa_X
  236. #define D3a_Y                    D1a_Y
  237. #define G1a_X                    CMPa_X
  238. #define G1a_Y                    CMPa_Y + MAX(f1aRows,f2aRows) + 1
  239. #define RIa_X                    INPa_X
  240. #define RIa_Y                    INPa_Y - 2
  241. #define RCa_X                    CMPa_X
  242. #define RCa_Y                    RIa_Y
  243. #define RGa_X                    RCa_X
  244. #define RGa_Y                    RCa_Y - 2
  245. #define CLa_X                    RSTa_X + MAX(F2a_COLS,F2b_COLS) + 1
  246. #define CLa_Y                    RSTa_Y + MAX(f1aRows, f2aRows) + 1
  247. #define NCa_X                    CLa_X
  248. #define NCa_Y                    CLa_Y - 2
  249. #define RHOa_X                   RIa_X
  250. #define RHOa_Y                   RIa_Y - 2
  251. #define G2a_X                    RECa_X
  252. #define G2a_Y                    G1a_Y
  253.  
  254. #define MAP_X                    RSTa_X + MAX(F2a_COLS, F2b_COLS) + 9
  255. #define MAP_Y                    RSTa_Y + (MAX(f1aRows,f2aRows) + 6) / 2
  256. #define D1_X                     MAP_X - 2
  257. #define D1_Y                     RSTb_Y + f2bRows - 1
  258. #define RB_X                     MAP_X - 2
  259. #define RB_Y                     MAP_Y - 2
  260. #define RM_X                     MAP_X
  261. #define RM_Y                     RB_Y
  262. #define RG_X                     RM_X
  263. #define RG_Y                     RGa_Y
  264. #define CL_X                     MAP_X - 6
  265. #define CL_Y                     (CLa_Y + CLb_Y) / 2
  266. #define NC_X                     CL_X + 2
  267. #define NC_Y                     CL_Y
  268. #define G_X                      MAP_X
  269. #define G_Y                      MAP_Y + f2bRows + 1
  270. #define RHO_X                    RB_X
  271. #define RHO_Y                    RB_Y - 2
  272. #define QU_X                     RECa_X
  273. #define QU_Y                     RCa_Y
  274. #define DRHO_X                   QU_X
  275. #define DRHO_Y                   RGa_Y
  276.  
  277. #define INPb_X                   INPa_X
  278. #define INPb_Y                   INPa_Y + MAX(f1aRows,f2aRows) + 5
  279. #define CMPb_X                   CMPa_X
  280. #define CMPb_Y                   INPb_Y
  281. #define RECb_X                   RECa_X
  282. #define RECb_Y                   CMPb_Y
  283. #define DELb_X                   DELa_X
  284. #define DELb_Y                   RECb_Y
  285. #define RSTb_X                   RSTa_X
  286. #define RSTb_Y                   DELb_Y
  287. #define D1b_X                    D1a_X
  288. #define D1b_Y                    DELb_Y - 2
  289. #define D2b_X                    D2a_X
  290. #define D2b_Y                    D1b_Y
  291. #define D3b_X                    D3a_X
  292. #define D3b_Y                    D2b_Y
  293. #define G1b_X                    G1a_X
  294. #define G1b_Y                    CMPb_Y - 2
  295. #define RIb_X                    RIa_X
  296. #define RIb_Y                    INPb_Y + MAX(f1bRows,f2bRows) + 1
  297. #define RCb_X                    RCa_X
  298. #define RCb_Y                    RIb_Y
  299. #define RGb_X                    RGa_X
  300. #define RGb_Y                    RCb_Y + 2
  301. #define CLb_X                    CLa_X
  302. #define CLb_Y                    D3b_Y
  303. #define NCb_X                    NCa_X
  304. #define NCb_Y                    CLb_Y + 2
  305. #define RHOb_X                   RHOa_X
  306. #define RHOb_Y                   RIb_Y + 2
  307. #define G2b_X                    RECb_X
  308. #define G2b_Y                    G1b_Y
  309.  
  310. #define STRING_LENGTH            30
  311.  
  312.  
  313. /* checks whether value is not equal to KRERR_NO_ERROR and if so, returns
  314. */
  315. #define CHECK_RETURN(ret_code)  if (ret_code != KRERR_NO_ERROR) \
  316.                                    return (ret_code)
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323. static int      bn_artmap_open = 0;
  324. static Widget   baseWidget;
  325. static Widget   artmapUnitWidget[4], artmapRowWidget[4];
  326.  
  327.  
  328.  
  329. static krui_err bn_artmap_make_layer (
  330.                             int    units,
  331.                             int    rows,
  332.                             int    cols,
  333.                             int    Xbegin,
  334.                             int    Ybegin,
  335.                             char  *name_prefix,
  336.                             int    unit_ttype,
  337.                             char  *actfuncname,
  338.                             char  *outfuncname,
  339.                             int    NoOfSites,
  340.                             char **SiteNames,
  341.                             char **SiteFuncNames);                        
  342. static krui_err bn_artmap_createNet (int f1aUnits, int f1aRows, int f2aUnits, int f2aRows, 
  343.                                      int f1bUnits, int f1bRows, int f2bUnits, int f2bRows);
  344. static void bn_artmap_donePROC (void);
  345. static void bn_artmap_createPROC (void);
  346.  
  347. /* end private definition section */
  348.  
  349. #endif
  350.